function e(e) {
    return e && e.__esModule ? e : {
        default: e
    };
}

function r(e, r) {
    var t = {};
    for (var n in e) r.indexOf(n) >= 0 || Object.prototype.hasOwnProperty.call(e, n) && (t[n] = e[n]);
    return t;
}

function t(e) {
    var t = e.desc, n = void 0 === t ? "" : t, o = e.showLoading, i = void 0 === o || o, a = r(e, [ "desc", "showLoading" ]), u = function(e) {
        wx.showModal({
            title: n + "失败",
            content: e,
            showCancel: !1
        });
    };
    if (n) {
        i && wx.showLoading({
            title: "" + n,
            mask: !0
        });
        var c = a.complete;
        a.complete = function() {
            wx.hideLoading(), c && c();
        };
    }
    return f.default.request(a).then(function(e) {
        var r = e.data;
        return 0 === r.code ? r.data : (n && u(r.message), console.log("api2: ", r), Promise.reject(r));
    }, function(e) {
        return n && u("网络问题，请稍后再试"), Promise.reject(e);
    });
}

function n(e) {
    var r = e.url, t = e.query, n = void 0 === t ? {} : t;
    return f.default.getUserInfo(n).then(function() {
        var e = Object.keys(n).map(function(e) {
            return e + "=" + n[e];
        }).join("&");
        return r += "?" + e, new Promise(function(e, t) {
            wx.downloadFile({
                url: r,
                success: function(r) {
                    var t = r.tempFilePath;
                    e(t);
                },
                fail: t
            });
        });
    }).catch(function(e) {
        console.log("Download Error: ", e);
    });
}

function o(e) {
    var r = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : l;
    if (e instanceof Array) return i(r, e);
    var t = {};
    return Object.keys(e).forEach(function(n) {
        t[n] = o(e[n], r + "/" + n);
    }), t;
}

function i(e, r) {
    var o = a(r, 1)[0], i = void 0 === o ? "GET" : o;
    return function() {
        var r = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {};
        switch (i) {
          case "DOWNLOAD":
            return Object.assign(r, {
                url: e
            }), n(r);

          default:
            return Object.assign(r, {
                url: e,
                method: i
            }), t(r);
        }
    };
}

Object.defineProperty(exports, "__esModule", {
    value: !0
});

var a = function() {
    function e(e, r) {
        var t = [], n = !0, o = !1, i = void 0;
        try {
            for (var a, u = e[Symbol.iterator](); !(n = (a = u.next()).done) && (t.push(a.value), 
            !r || t.length !== r); n = !0) ;
        } catch (e) {
            o = !0, i = e;
        } finally {
            try {
                !n && u.return && u.return();
            } finally {
                if (o) throw i;
            }
        }
        return t;
    }
    return function(r, t) {
        if (Array.isArray(r)) return r;
        if (Symbol.iterator in Object(r)) return e(r, t);
        throw new TypeError("Invalid attempt to destructure non-iterable instance");
    };
}(), u = e(require("./api-config")), c = e(require("./config")), f = e(require("./api")), l = c.default.host, s = o(u.default);

exports.default = s;